<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>index.js - Documentation</title>

    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Externals</h3><ul><li><a href="external-EventEmitter.html">EventEmitter</a></li></ul><h3>Events</h3><ul><li><a href="external-EventEmitter.html#event:error">error</a></li></ul><h3>Namespaces</h3><ul><li><a href="Express.html">Express</a><ul class='methods'><li data-type='method'><a href="Express.html#.Router">Router</a></li></ul></li></ul><h3>Global</h3><ul><li><a href="global.html#exports">exports</a></li></ul>
</nav>

<div id="main">

    <h1 class="page-title">index.js</h1>

    <section>
        <article>
            <pre class="prettyprint source linenums"><code>'use strict';
/**
 * Express framework
 *
 * @namespace Express
 *
 * @see {@link https://expressjs.com/en/4x/api.html}
 */

/**
 * Express Request
 *
 * @memberof Express
 * @inner
 *
 * @typedef Request
 *
 * @see {@link https://expressjs.com/en/4x/api.html#req}
 */

/**
 * Express Response
 *
 * @memberof Express
 * @inner
 *
 * @typedef Response
 *
 * @see {@link https://expressjs.com/en/4x/api.html#res}
 */

/**
 * Express Router
 *
 * @function Express.Router
 *
 * @see {@link https://expressjs.com/en/4x/api.html#router}
 */
const Router = require('express').Router,
      config = {
          userAgent:    'Express Middleware - GitHub API',
          apiRoot:      'https://api.github.com'
      };

/**
 * API configuration
 *
 * @typedef {object} APIConfig
 *
 * @property {string}   AppID
 * @property {string}   AppSecret
 * @property {string[]} [AppScope]
 * @property {string}   [HookSecret] - Secret code of a **Web hook**
 */

/**
 * Session data
 *
 * @typedef {object} SessionData
 *
 * @property {string} AccessToken - Access token of **OAuth 2.0**
 *
 * @see {@link https://developer.github.com/v3/users/#get-the-authenticated-user|More data about the Login User}
 */

/**
 * Session handler
 *
 * @callback SessionHandler
 *
 * @param {Express~Request}  request
 * @param {Express~Response} response
 * @param {SessionData}      [data]
 */

/**
 * Local configuration
 *
 * @typedef {object} LocalConfig
 *
 * @property {SessionHandler} setSession
 * @property {SessionHandler} getSession
 * @property {string}         [successURL=""] - URL to redirect when OAuth succeed
 */

/**
 * Middleware instance
 *
 * @typedef {object} Middleware
 *
 * @property {Express.Router}        router
 * @property {external:EventEmitter} emitter
 */

/**
 * @global
 *
 * @param {APIConfig}   API_Config
 * @param {LocalConfig} Local_Config
 *
 * @return {Middleware}
 */
module.exports = function (API_Config, Local_Config) {

    const router = Router();

    Object.assign(config, API_Config, Local_Config);

    require('./OAuth').call(router, config);

    require('./Language').call(router, config);

    const emitter = require('./Hook').call(router, config);

    require('./Proxy').call(router, config);

    return {
        router:     router,
        emitter:    emitter
    };
};
</code></pre>
        </article>
    </section>

</div>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>
